package com.example.fp.wrt.controller;
import com.example.fp.wrt.entity.Liveness;
import com.example.fp.cgc.code.logAnno.LogAnno;
import com.example.fp.wrt.mapper.LivenessMapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 说明: Liveness表操作
 * 编写人: 魏仁涛
 * 编写时间: 2019-12-31
 * 修改时间; 2019-12-31
 * 编码问题
 */
@CrossOrigin
@RestController
public class LivenessController {
    @Autowired
    private LivenessMapper livenessMapper;

    @LogAnno(operateType = "应用添加")
    @ApiOperation("应用添加")
    @PostMapping ("/insertliveness")
    public int insertLiveness(Liveness liveness){
        return livenessMapper.insert(liveness);
    }

    @LogAnno(operateType = "应用删除")
    @ApiOperation("应用删除")
    @GetMapping("/deleteliveness")
    public int deleteLiveness(int id){
        return livenessMapper.deleteById(id);
    }
    @LogAnno(operateType = "应用修改")
    @ApiOperation("应用修改")
    @GetMapping("/updateliveness")
    public int updateLiveness(Liveness liveness){
        return livenessMapper.updateById(liveness);
    }

    @LogAnno(operateType = "应用查询")
    @ApiOperation("应用查询")
    @GetMapping("/selectliveness")
    public Liveness selectLiveness(int id){
        return livenessMapper.selectById(id);
    }

    @LogAnno(operateType = "应用列表查询")
    @ApiOperation("应用列表查询")
    @RequestMapping(value = "/getLivenesslist",method = RequestMethod.PUT)
    public List<Liveness> selectLivenessList() { return livenessMapper.selectAllLiveness(); }

    @ApiOperation("echart柱形图")
    @RequestMapping(value = "/echartzhuxingtu",method = RequestMethod.PUT)
    public List<Liveness> echartzhuxingtu() {
    return livenessMapper.echartzhuxingtu();
    }

    @ApiOperation("echart饼图")
    @RequestMapping(value = "/echartbingtu",method = RequestMethod.PUT)
    public List<Liveness> echartbingtu() {
        return livenessMapper.echartbingtu();
    }
}
